package sanshui.system.trade.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import sanshui.system.trade.db.entity.TradeReport;
import sanshui.system.trade.db.entity.TradeReportExample;
import sanshui.system.trade.db.mapper.SelfTradeReportMapper;
import sanshui.system.trade.db.mapper.TradeReportMapper;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

@Service
public class TradeReportServiceImpl extends ServiceImpl<SelfTradeReportMapper, TradeReport> implements ITradeReportService  {
    @Resource
    TradeReportMapper tradeReportMapper;

    @Override
    public List<TradeReport> findReportsByAccIdOrWorkerId(Long accId, Long workId) {
        TradeReportExample tradeReportExample = new TradeReportExample();
        TradeReportExample.Criteria criteria = tradeReportExample.createCriteria();
        if (accId != null){
            criteria.andAccIdEqualTo(accId);
        }
        if (workId != null){
            criteria.andWorkerIdEqualTo(workId);
        }
        return tradeReportMapper.selectByExample(tradeReportExample);
    }

    @Override
    public int saveReportBatch(List<TradeReport> reports) {
        return saveBatch(reports)? 1:0;
    }

}
